package com.woniuxy.oa.dao.provider;


import com.woniuxy.oa.entity.query.SalaryQuery;
import org.apache.ibatis.jdbc.SQL;

/**
 * @Auther: 毓
 * @Date: 2019/12/25 12:03
 * @Description:
 */
public class SalaryProvider {
    public String select(SalaryQuery salary) {
        return new SQL() {
            {
                SELECT("s.*,u.empno empNo,u.level empLevel,u.name empName,u.gender empGender,d.deptname deptName,d.id deptId");
                FROM("oa_salary s,oa_emp u");
                LEFT_OUTER_JOIN("oa_dept d on d.id=u.deptid");
                WHERE("u.id=s.employeeid");
                if (salary.getEmpName() != null && salary.getEmpName().trim().length() != 0) {
                    WHERE("u.name like  concat(\"%\",#{salary.empName},\"%\")");
                }
                if (salary.getDeptId() != null&&salary.getDeptId().trim().length() != 0) {
                    WHERE("d.id=#{salary.deptId} ");
                }
                if (salary.getGenderQuery() != null && salary.getGenderQuery().trim().length() != 0) {
                    WHERE("u.gender=#{salary.genderQuery}");
                }
            }
        }.toString();
    }
}
